import MySocket from '@/utils/mqtt';
import { listenWsCallback } from '@/socket/basiclisten';

let listenClass: any = new listenWsCallback();

const BasicWsSocket = (sessionId) => {
  MySocket.mqttReconnect(
    `data/app${sessionId ? `/${sessionId}` : ''}`,
    null,
    (res) => {
      const method = res?.content?.event_name;
      if (listenClass.__proto__.hasOwnProperty(method)) {
        listenClass[method](res?.content?.data);
      }
    }
  );
};

export default BasicWsSocket;
